package com.zj.small.service.impl;

import com.zj.small.mapper.UserMapper;
import com.zj.small.pojo.User;
import com.zj.small.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import static com.zj.small.util.Md5Util.StringInMd5;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public User findByUsername(String username) {
        return userMapper.findByUsername(username);
    }

    @Override
    public void register(String username, String password) {

        String pw = StringInMd5(password);
        // 密码加密设置
        userMapper.add(username,pw);
    }

    @Override
    public User findByUserEmail(String email) {
        return userMapper.findByUserEmail(email);
    }

    @Override
    public void addUser(String username, String password, String email) {
        userMapper.addUser(username,password,email);
    }


}
